import React, {PureComponent} from 'react'
import Bar from '../component/scheduling/bar'
import Pie from '../component/scheduling/pie'
import TallyingTable from '../component/scheduling/table'
import '../../css/scheduling.scss'
import Tabs from '../Tabs'
import '../../css/tab.scss'
import '../Tabs/tab.scss'
import {connect} from 'react-redux'
import {getScheduling, getSchedulingStat} from '../action/map.action'

const Tab = Tabs.Tab;

class Scheduling extends PureComponent {
    constructor() {
        super()
        this.company = ['H3C', '东信', '信华', '达创', '统合', '双赢', '飞旭']
    }

    componentDidMount() {
        const {dispatch} = this.props
        /*获取排产计划*/
        dispatch(getScheduling({factoryName: 'H3C'}))
        dispatch(getSchedulingStat({factoryName: 'H3C'}))
    }

    handChange = (index) => {
        const {dispatch} = this.props
        /*获取排产计划*/
        dispatch(getScheduling({factoryName: this.company[index]}))
        dispatch(getSchedulingStat({factoryName: this.company[index]}))
    }


    render() {
        return (
            <div>
                <div className="full-container">
                    <div style={{width: '100%', height: 'auto'}}>
                        <Tabs defaultActiveKey="1" className='custom-tab' onChange={this.handChange}>
                            { this.company.map((com, i) => {
                                return <Tab tab={com} key={`company-${i}`}>

                                </Tab>
                            })}
                        </Tabs>
                    </div>
                    <div style={{width: '100%', height: 'calc(100% - 6rem)'}}>
                        <div className="scheduling-chart">
                            <Pie/>
                            <Bar/>
                        </div>
                        <div className="scheduling-table">
                            <TallyingTable/>
                        </div>
                    </div>
                </div>
            </div>
        )
    }

}


function mapStoreToProps({}) {
    return {}
}

export default connect(mapStoreToProps)(Scheduling)